#!/bin/bash

# Get the directory of the script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Change to the script directory
cd "$DIR"

# Create necessary directories
mkdir -p logs
mkdir -p temp
mkdir -p output
mkdir -p models

# Activate virtual environment if it exists
if [ -d "venv" ]; then
    source venv/bin/activate
fi

# Start the application in the background
nohup python src/main.py > logs/nohup.out 2>&1 &

# Save the process ID
echo $! > video_trans.pid

echo "Video Translation Service started with PID $(cat video_trans.pid)"
echo "Check logs/video_trans.log for application logs"
echo "Check logs/nohup.out for startup logs"